import pinia from '@/store'
import useSettingsStore from '@/store/modules/settings'

// 固定路由（默认路由）
let constantRoutes = [
    {
        path: '/',
        redirect: '/home'
    },
    {
        path: '/home',
        component: () => import('@/layout/index.vue'),
        meta: {
            title: () => {
                return useSettingsStore().dashboard.title
            },
            breadcrumb: false
        },
        children: [
            {
                path: '',
                name: 'Home',
                component: () => import('@/views/Home/index.vue'),
                meta: {
                    breadcrumb: false,
                    name: 'Home',
                    cache: true,
                    title: '首页'
                }
            },
            {
                path: '/projects',
                name: 'Projects',
                component: () => import('@/views/Projects/index.vue'),
                meta: {
                    breadcrumb: false,
                    name: 'Projects',
                    cache: true,
                    title: '工程项目一览表'
                }
            },
            {
                path: '/contract',
                name: 'Contract',
                component: () => import('@/views/Contract/index.vue'),
                meta: {
                    breadcrumb: false,
                    name: 'Contract',
                    cache: true,
                    title: '合同明细'
                }
            },
            {
                path: '/branchProject',
                name: 'BranchProject',
                component: () => import('@/views/BranchProject/index.vue'),
                meta: {
                    breadcrumb: false,
                    name: 'BranchProject',
                    cache: true,
                    title: '专业分公司立项'
                }
            },
            {
                path: '/myProject',
                name: 'MyProject',
                component: () => import('@/views/MyProject/index.vue'),
                meta: {
                    breadcrumb: false,
                    name: 'MyProject',
                    cache: true,
                    title: '我的立项'
                }
            },
            {
                path: '/todoProject',
                name: 'TodoProject',
                component: () => import('@/views/TodoProject/index.vue'),
                meta: {
                    breadcrumb: false,
                    name: 'TodoProject',
                    cache: true,
                    title: '我的待办'
                }
            },
            {
                path: '/completed',
                name: 'Completed',
                component: () => import('@/views/Completed/index.vue'),
                meta: {
                    breadcrumb: false,
                    name: 'Completed',
                    cache: true,
                    title: '我的已办'
                }
            }
        ]
    },
    {
        path: '/:all(.*)*',
        name: 'notFound',
        component: () => import('@/views/[...all].vue'),
        meta: {
            title: '找不到页面',
            name: 'notFound',
            cache: true
        }
    }
]

import generatedRoutes from 'virtual:generated-pages'

if (useSettingsStore(pinia).app.routeBaseOn === 'filesystem') {
    constantRoutes = generatedRoutes.filter(item => {
        return item.meta?.enabled !== false && item.meta?.constant === true
    })
}

export {
    constantRoutes
}
